VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "ApiCWPSTRUCT"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Option Explicit

' ##MODULE_DESCRIPTION This class implements a wrapper for CWPSTRUCT

Private Type CWPSTRUCT
    lParam As Long
    wParam As Long
    Message As Long
    hWnd As Long
End Type

Public lParam As Long
Public wParam As Long
Public Message As Long
Public hWnd As Long

Public CreatedOK As Boolean

'\\ Private memory handling functions
Private Declare Sub CopyMemoryCWPStruct Lib "kernel32" Alias "RtlMoveMemory" (Destination As CWPSTRUCT, ByVal Source As Long, ByVal Length As Long)
Private Declare Function IsBadReadPtrCWPStruct Lib "kernel32" Alias "IsBadReadPtr" (ByVal lp As Long, ByVal ucb As Long) As Long
Private Declare Function IsBadWritePtrCWPStruct Lib "kernel32" Alias "IsBadWritePtr" (ByVal lp As Long, ByVal ucb As Long) As Long

'\\ --[CreateFromPointer]---------------------------------------------
'\\ Fills this CWPStruct object from the location poiunted to by
'\\ lpCWPStruct
'\\ VB.NET Porting note: This function should be replaced with an override
'\\ of the New() for correctness
'\\ ----------------------------------------------------------------------------------------
'\\ (c) 2001 - Merrion Computing.  All rights  to use, reproduce or publish this code reserved
'\\ Please check http://www.merrioncomputing.com for updates.
'\\ ----------------------------------------------------------------------------------------
Friend Function CreateFromPointer(lpCWPStruct As Long) As Boolean

Dim ftThis As CWPSTRUCT

CreatedOK = False

If Not IsBadReadPtrCWPStruct(lpCWPStruct, Len(ftThis)) Then
    Call CopyMemoryCWPStruct(ftThis, lpCWPStruct, Len(ftThis))
    If Err.LastDllError = 0 Then
        With ftThis
            hWnd = .hWnd
            lParam = .lParam
            Message = .Message
            wParam = .wParam
            If Err.LastDllError = 0 Then
                CreatedOK = True
            End If
        End With
    End If
End If

CreateFromPointer = CreatedOK

End Function

